function price=constmc1
Npath = 100000;

global K t T r
K=4; t=0; T=1; r=0.05;
global ay v my; 
ay=100; v=1; my=1;
global rho

rho=0.5;


X=0;
for ii=1:Npath
    X = X+max(getaX-K,0);
    disp(ii);
end

price = exp(-r*(T-t))*X/Npath;
end

function XT=getaX

global T t r ay v my rho

by = v*sqrt(2*ay); 

X=zeros(5001,1); Y=X; Z=X; X(1)=5;
Y(1)=1; Z(1)=1; dt = (T-t)/5000;



for ii=2:5001
    w0 = randn(1); w1hat = randn(1); w1 = rho*w0+sqrt(1-rho^2)*w1hat;
    Y(ii) = Y(ii-1)+ay*(my-Y(ii-1))*dt + by*sqrt(dt)*w1;
    sigma1= 2+sin(Y(ii-1));
    X(ii) = X(ii-1)+r*X(ii-1)*dt+sigma1*X(ii-1)*sqrt(dt)*w0;
end
XT=X(5001);
end